#!/bin/bash

#User-defined information
export node=3
export node_ip="192.168.20.183 192.168.20.96 192.168.20.171"
export node_name="master-01 master-02 master-03"
export node_pass="123456 123456 123456"
export apiserver_vip="192.168.20.240"
export apiserver_vip_port="4443"
export flaneld_interface="ens33"
export vip_interface="ens33"
export haproxy_name="admin" 
export haproxy_pass="123456"
export haproxy_status_port="8000"

#install Dir
export k8s_install_dir="/usr/local/k8s"

#CA Dir
export kubernetes_ca="/etc/kubernetes"

#k8s clusert
export svc_cidr="10.254.0.0/16"
export kubernetes_svc_ip="10.254.0.1"
export kubernetes_dns_ip="10.254.0.2"
export cluster_cidr="172.10.0.0/16"
export node_port_range="30000-32767"
export cluster_dns_domain="cluster.local"
export apiserver="https://${apiserver_vip}:${apiserver_vip_port}"

#etcdAddress
i=0
for etcd_ip in $node_ip
do
let i++
  echo -e "`echo ${node_name} | cut -d " " -f $i`=https://${etcd_ip}:2380,\c" >> ./test/etcd-ip-communication.txt
  echo -e "https://${etcd_ip}:2379,\c" >> ./test/etcd-ip.txt
done

export etcd_endpoint="`sed 's/.$//' ./test/etcd-ip.txt`"
export etcd_communication="`sed 's/.$//' ./test/etcd-ip-communication.txt`"
rm -rf ./test/etcd-ip.txt ./test/etcd-ip-communication.txt 

#flaneld config
export flanneld_etcd_prefix="/kubernetes/network"

# kind: EncryptionConfig
encryption_config=$(head -c 32 /dev/urandom | base64)
